package response

import (
	"encoding/json"
	"strings"
)

const (
	Code_Error_Unknow          = -1
	Code_Success               = 0
	Code_Error_OperationFailed = 1
	Code_Error_InVaildMethod   = 22
	Code_Error_ParamError      = 23
	Code_Error_SessionIllegal  = 24
	Code_Error_ServerError     = 999
	Code_Error_BidIsNull       = 1001
	Code_Error_TargetNotExists = 1002
)

const (
	Info_Error_Unknow          = "unknow error"
	Info_Success               = "ok"
	Info_Error_OperationFailed = "operation failed"
	Info_Error_InVaildMethod   = "invaild method"
	Info_Error_ParamError      = "param error"
	Info_Error_SessionIllegal  = "session illegal"
	Info_Error_ServerError     = "server error"
	Info_Error_BabyIdIsNull    = "bid is null"
	Info_Error_TargetNotExists = "target object not exists"
)

type Response struct {
	Message string
	Ret     int
	Data    interface{}
}

func (r *Response) FormatJsonString() string {
	result, err := json.Marshal(r)
	if err != nil {
		return ""
	}

	return strings.ToLower(string(result))
}
